<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,user-scalable=no,minimal-ui">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../img/asset-favico.ico">
    <title>编辑信息</title>
    <link rel="stylesheet" href="../css/page-health-orderInfo.css" />
    <link rel="stylesheet" href="../plugins/elementui/index.css" />
    <script src="../plugins/jquery/dist/jquery.min.js"></script>
    <script src="../plugins/healthmobile.js"></script>
    <script src="../plugins/datapicker/datePicker.js"></script>
    <script src="../plugins/vue/vue.js"></script>
    <script src="../plugins/vue/axios-0.18.0.js"></script>
    <script src="../plugins/elementui/index.js"></script>
    <script>
        var id = getUrlParam("id");
    </script>
</head>
<body data-spy="scroll" data-target="#myNavbar" data-offset="150">
<div id="app" class="app">
    <!-- 页面头部 -->
    <div class="top-header">
        <span class="f-left"><i class="icon-back" onclick="history.go(-1)">返回</i></span>
        <span class="center">传智健康</span>
        <span class="f-right"><i class="icon-more"></i></span>
    </div>
    <!-- 页面内容 -->
    <div class="contentBox">
        <div class="form-info">
            <div class="info-title">
                <span class="name"><h3>信息详情</h3>（初始密码为：123456）</span>
            </div>
            <div class="input-old">
                <label>原密码</label>
                <input id="old" @blur="findOldPassword" v-model="oldpassword" type="password" class="input-clear" placeholder="请输入原始密码">
                <span style="color: #85ff55">{{message}}</span>
            </div>
            <div class="input-new">
                <label>新密码</label>
                <input v-model="newpassword" type="password" class="input-clear" placeholder="请输入需要更改的密码">
            </div>
            <div class="input-new2">
                <label>再次输入</label>
                <input v-model="new2password" type="password" class="input-clear" placeholder="请再次输入需要更改的密码">
            </div>
            <div class="box-button">
                <button @click="submitOrder()" type="button" class="btn order-btn">修改信息</button>
            </div>
        </div>
    </div>
</div>
</div>
<script >
    var vue = new Vue({
        el:'#app',
        data:{
            oldpassword:'',
            newpassword:'',
            new2password:'',
            message:'',
            flag:false
        },
        created() {

        },
        methods: {
            findOldPassword(){
                //发送ajax请求 把页面输入的密码提交到后台进行对比
                axios.post("/member/findOldPassword.do?oldPassword="+this.oldpassword).then((res)=>{
                    this.message=res.data.message;
                    this.flag = res.data.flag;

                });
            },
            submitOrder(){
                if (this.flag) {
                    if (this.newpassword == this.new2password) {
                        if(this.newpassword!=''&&this.newpassword!=null&&this.new2password!=''&&this.new2password!=null){
                            axios.get("/member/updatePassword.do?newpassword="+this.newpassword).then((res)=>{
                                if (res.data.flag){
                                    this.$message.success(res.data.message);
                                    location.href = "/pages_login/member.html";
                                }else {
                                    this.$message.error(res.data.message)
                                }
                            });
                        }
                    }else{
						this.$message.error("两次输入密码不一致,请重试!")
					}
                }else {
                    this.$message.error("请先验证原密码!")
                }
            }
        }
    });
</script>
</body>
</html>